/**
 * 
 */
package de.homer.adapter.domain;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * This class represents a {@link de.homer.adapter.interfaces.HomeRPlugin} in
 * it's configured state. This means that the related
 * {@link de.homer.adapter.interfaces.HomeRPlugin} is active in the homeR server
 * and can be used by clients.
 * 
 * @author André Stannek
 * 
 */
@Entity
@Table(name = "configuredPlugins")
@XmlRootElement
public class ConfiguredPlugin {

	/**
	 * Database ID. Should only be set by hibernate.
	 */
	@Id
	@Column(name = "id")
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Integer id;

	/**
	 * The Meta Information describing the plugin that is configured.
	 */
	@ManyToOne(cascade = CascadeType.ALL)
	private PluginMetaInformation configuredPlugin;

	/**
	 * 
	 */
	@OneToOne(cascade = CascadeType.ALL)
	private PluginConfiguration configuration;

	/**
	 * The name of this configuration. This can be freely selected by the user.
	 */
	@Column(name = "name")
	private String name;

	/**
	 * @return The Meta Information describing the plugin that is configured.
	 */
	public final PluginMetaInformation getConfiguredPlugin() {
		return configuredPlugin;
	}

	/**
	 * @param configuredPlugin
	 *            The Meta Information describing the plugin that is configured.
	 */
	public final void setConfiguredPlugin(
			final PluginMetaInformation configuredPlugin) {
		this.configuredPlugin = configuredPlugin;
	}

	/**
	 * @return the name of this configuration
	 */
	public final String getName() {
		return name;
	}

	/**
	 * @param name
	 *            the name of this configuration
	 */
	public final void setName(final String name) {
		this.name = name;
	}

	/**
	 * @return the configuration
	 */
	public final PluginConfiguration getConfiguration() {
		return configuration;
	}

	/**
	 * @param configuration
	 *            the configuration to set
	 */
	public final void setConfiguration(final PluginConfiguration configuration) {
		this.configuration = configuration;
	}
}
